#include<bits/stdc++.h>
#define y1 Y1
#define fi first
#define endl "\n"
#define se second
#define PI acos(-1)
#define int long long
#define pb(x) push_back(x)
#define PII pair<int, int>
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define _for(i, a, b) for(int i = a; i <= b; ++i)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;

const int N = 1e5 + 10;
struct ty {
	int l , r;
}a[N];

bool cmp(ty x, ty y) {
	return x.l < y.l;
}

int ret, n;
void hebin() {
	bool flag;
    int l = a[1].l, r = a[1].r;
	for(int i = 2; i <= n; ++i) {
		flag = false;
		if(a[i].l <= r) {
			l = min(a[i].l, l);
			r = max(a[i].r, r);
		}
		else {
			ret++;
			l = a[i].l;
			r = a[i].r;
		}
	}
	ret++;	
}

signed main() {
	IOS;
	cin >> n;
	_for(i, 1, n) {
		cin >> a[i].l >> a[i].r;
	} 
	sort(a + 1, a + n + 1, cmp);
	hebin();
	cout << ret << endl;
	return 0;
}

